/***************************************************************************
 *  Filename: gpsreader.h
 *  Class: GPSReader
 *  
 *  Copyright 2012  Jacco van der Spek
 *  <jaccovdspek@gmail.com>
 *
 *  Copyright 2012  Mario Henrique Voorsluys
 *  <forcaeluz@gmail.com>
 *  
 ****************************************************************************/

/*
 *
 * This file is part of %ProjectName%.
 *
 *    %ProjectName% is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    %ProjectName% is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with %ProjectName%.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef GPSHANDLER_H
#define GPSHANDLER_H

#include <QObject>
#include <QStringList>
#include <QList>
#include <qmath.h>
#include <QRegExp>
#include <QChar>
#include "gpsdata.h"
#include "communicationhandler.h"



class GPSHandler : public QObject
{
    Q_OBJECT
public:
    explicit GPSHandler(QString uartPort = "/dev/ttyUSB0", QObject *parent = 0);
    void handleInput (QString rawdata);
    GPSData* calcCoordTarget(double startlat, double startlong, double bearing, double distance);
    GPSData* getBufferedGPSData();
    QList<GPSData*> getList();

private:
    QList<GPSData*> gpslist;
    QString checkSumCalculation(QString cleaninput);
    QString removeLeadingzeros(QString s);
    void setupGPS(QString, QString);
    float parseLatitude(QString latitude);
    float parseLongitude(QString longitude);
    QString rmc;
    QString tenhz;
    CommunicationHandler gpsdatareceiver;

signals:

public slots:
    void receiveGPSData();

};

#endif // GPSHANDLER_H
